assist: operate on all files in working tree by default
authorJoey Hess <joeyh@joeyh.name>
Fri, 19 May 2023 18:47:05 +0000 (14:47 -0400)
committerJoey Hess <joeyh@joeyh.name>
Fri, 19 May 2023 18:47:05 +0000 (14:47 -0400)
Consistency with sync and internal consistency is more important than
consistency with the assistant, which is not itself consistent about
what it does when run in a subdirectory.

Note that with -C, it will still commit staged changes to files outside
the directory. Like sync does. Presumably if the user is manually
staging things, then running this command, they intend to build up a
commit.

Sponsored-by: unqueued on Patreon
Command/Assist.hs
doc/git-annex-assist.mdwn
doc/todo/Having___39__git_annex_sync__39___optionally_add/comment_12_8327e0a3f3d4bf35c52b1f2f4089dcbc._comment [new file with mode: 0644]

index 6075b63ceabfe20f337c11866e2475d2f32c949f..fc6db063c7edbb10bc929f070e266d34bc941b8b 100644 (file)
@@ -22,11 +22,13 @@ cmd = withAnnexOptions [jobsOption, backendOption] $
 
 myseek :: Command.Sync.SyncOptions -> CommandSeek
 myseek o = startConcurrency transferStages $ do
-       -- Run before prepMerge so it adds only files in the current
-       -- directory and below, not new files elsewhere in the working
-       -- tree.
+       -- Changes to top of repository, so when this is run in a
+       -- subdirectory, it will still default to adding files anywhere in
+       -- the working tree.
+       Command.Sync.prepMerge
+
        Command.Add.seek Command.Add.AddOptions
-               { Command.Add.addThese = []
+               { Command.Add.addThese = Command.Sync.contentOfOption o
                , Command.Add.batchOption = NoBatch
                , Command.Add.updateOnly = False
                , Command.Add.largeFilesOverride = Nothing
@@ -37,5 +39,4 @@ myseek o = startConcurrency transferStages $ do
        -- Flush added files to index so they will be committed.
        Annex.Queue.flush
 
-       Command.Sync.prepMerge
        Command.Sync.seek' o
index 35be1d8072ba2b176f53e20300cf4f2ad0de9827..0a897ae1ae301b14b7e3375205c5958ee85f2061 100644 (file)
@@ -13,11 +13,14 @@ and syncing with remotes. It's the simplest possible way to use git-annex
 at the command line, since only this one command needs to be run on a
 regular basis.
 
-This command first adds any new files (in the current directory and
-its children) to the repository, and commits those as well as any
-modified files. Then it does the equivilant of running
+This command first adds any new files to the repository, and commits those
+as well as any modified files. Then it does the equivilant of running
 [[git-annex-pull](1) followed by [[git-annex-push]](1).
 
+This command operates on all files in the whole working tree,
+even when ran in a subdirectory. To limit it to operating on files in a
+subdirectory, use the `--content-of` option.
+
 To block some files from being added to the repository, use `.gitignore`
 files.
 
@@ -31,6 +34,12 @@ files that it does not match will instead be added with `git add`.
 
   Use this option to specify a commit message.
 
+* `--content-of=path` `-C path`
+
+  Only add, pull, and push files in the given path.
+
+  This option can be repeated multiple times with different paths.
+
 * Also all options supported by [[git-annex-pull]](1) and
   [[git-annex-push]](1) can be used.
 
diff --git a/doc/todo/Having___39__git_annex_sync__39___optionally_add/comment_12_8327e0a3f3d4bf35c52b1f2f4089dcbc._comment b/doc/todo/Having___39__git_annex_sync__39___optionally_add/comment_12_8327e0a3f3d4bf35c52b1f2f4089dcbc._comment
new file mode 100644 (file)
index 0000000..5a2a203
--- /dev/null
@@ -0,0 +1,15 @@
+[[!comment format=mdwn
+ username="joey"
+ subject="""comment 12"""
+ date="2023-05-19T18:37:28Z"
+ content="""
+I'm also not too happy with the inconsistency of assist committing all staged
+changes and syncing all file contents, but only adding files in the cwd.
+
+I suppose that consistency with the assistant doesn't really matter. The
+assistant's behavior when ran in a subdirectory is surprising,
+inconsistent, and undocumented.
+
+So I'm going to change assist to add all files. Except when -C is used,
+then only add files in the specified directory.
+"""]]